home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1998 November: Tool Chest / Dev.CD Nov 98 TC.toast / Sample Code / Devices / ADB Key Spy 1.0.1b3 / ADBKS Common.h < prev    next >
Encoding:
Text File  |  1997-03-07  |  2.3 KB  |  83 lines  |  [TEXT/R*ch]

  1.     //
  2.     //    from 'ADB Key Spy' • Pete Gontier • gurgle@apple.com
  3.     //    Macintosh Developer Technical Support
  4.     //    © 1995,1996 Apple Computer, Inc.
  5.     //
  6.     //    Changes:
  7.     //
  8.     //        when        who        what
  9.     //        --------------------------------------------------------------
  10.     //        01/11/96    PG        copied from another project,
  11.     //                            merged with various parts of old
  12.     //                            ADB Key Spy
  13.     //
  14.  
  15. #pragma once
  16.  
  17. #ifndef __DESKBUS__
  18. #    include <DeskBus.h>
  19. #endif
  20.  
  21.     //
  22.     //    kMaxKeyCode
  23.     //
  24.     //    GetKeys returns four 32-bit quantities for its key map, and with
  25.     //    each bit corresponding to a key, that 32*4==128 keys. I don't know
  26.     //    if keyboards are capable of supporting more keys, but it's unlikely
  27.     //    anybody cares about key codes that high simply because GetKeys
  28.     //    can't report them. We use 127 because key codes start at 0.
  29.     //
  30.  
  31. static const unsigned char kMaxKeyCode = 127;
  32.  
  33.     //
  34.     //    tKeyboardInfo
  35.     //
  36.     //    This structure describes each keyboard discovered during AKS_AcquireKeyboards.
  37.     //    In it we store info from the service routine for the keyboard before we replace it,
  38.     //    plus a key map. We use a byte for each entry in the key map mostly for historical
  39.     //    reasons. (There used to be one key map for all keyboards; each entry was a counter.)
  40.     //    Now it has a byte per entry simply because I am too lazy to write the bit-twiddling
  41.     //    code to make it one bit per entry.
  42.     //
  43.     //    We maintain a simple linked list of these structures. Client code doesn't need to
  44.     //    worry about this structure; it's just here for the benefit of the code resource.
  45.     //
  46.  
  47. #if PRAGMA_ALIGN_SUPPORTED
  48. #    pragma options align=mac68k
  49. #endif
  50.  
  51. typedef struct
  52. {
  53.     unsigned char                raw;
  54.     Boolean                        noXor, Xor;
  55.     unsigned char                bits;
  56.     unsigned char                pstring [ ];
  57. }
  58. tKeyMapResourceException;
  59.  
  60. typedef struct // for corroboration, see "SysTypes.r"
  61. {
  62.     unsigned short                id;
  63.     unsigned short                vers;
  64.     unsigned char                map [kMaxKeyCode + 1];
  65.     unsigned short                exceptionCount;
  66.     tKeyMapResourceException    exceptions [ ];
  67. }
  68. tKeyMapResource, *tKeyMapResourceP, **tKeyMapResourceH;
  69.  
  70. typedef struct tKeyboardInfo
  71. {
  72.     ADBServiceRoutineUPP    dbServiceRtPtr;
  73.     Ptr                        dbDataAreaAddr;
  74.     unsigned char            virtualKeyMap [kMaxKeyCode + 1];
  75.     tKeyMapResourceH        keyMapResH;
  76.     struct tKeyboardInfo    *next;
  77. }
  78. tKeyboardInfo, *tKeyboardInfoP;
  79.  
  80. #if PRAGMA_ALIGN_SUPPORTED
  81. #    pragma options align=reset
  82. #endif
  83.